package com.gxa.hotel.core.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonUtil {

    private static ObjectMapper objectMapper;

    static {
        objectMapper=new ObjectMapper();
    }

    public static <T> T read(String jsonString,Class<T> clazz) throws JsonProcessingException {
        T t = objectMapper.readValue(jsonString, clazz);
        return t;
    }

    public static String write(Object object) throws JsonProcessingException {
        String s = objectMapper.writeValueAsString(object);

        return s;
    }
}
